<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('title'); ?>
	Add Offer
<?php $this->_endblock(); ?>

<?php $this->_block('contents'); ?>
<div id="content" class="box">
	<h1>Add Offer</h1>
		<?php if (isset($infos)) 
				{
					foreach ($infos as $info)
					{
		?>
				<p class="msg info"><?php echo $info;?></p>
		<?php		}
				}
		?>
		<fieldset>
			<legend>Add Offer</legend>
		<?php if (isset($errors)) 
				{
					foreach ($errors as $error)
					{
		?>
				<p class="msg error"><?php echo $error;?></p>
		<?php		}
				}
		?>
		<form method="post" action="<?php echo url('offer/insert');?>">
		<input type="hidden" name="id" value="<?php echo isset($id) ? $id : ''; ?>" />
		
		<table class="nostyle">
			<tr>
				<td>Name:</td>
				<td><input type="text" class="input-text" name="name" value="<?php if (isset($name)) echo $name;?>"/></td>
			</tr>
			<tr>
				<td>Availability:</td>
				<td>
					<input type="radio" name="availability" value="0" <?php echo ('0' == $availability) ? 'checked="checked"' : ''; ?>/><label class="radio-label">Public</label>
					<input type="radio" name="availability" value="1" <?php echo ('1' == $availability) ? 'checked="checked"' : ''; ?>/><label class="radio-label">Private</label>
				</td>
			</tr>
			<tr>
				<td>Type:</td>
				<td>
					<input type="radio" name="type" value="CPM" <?php echo ('CPM' == $type) ? 'checked="checked"' : ''; ?>/><label class="radio-label">CPM</label>
					<input type="radio" name="type" value="CPC" <?php echo ('CPC' == $type) ? 'checked="checked"' : ''; ?>/><label class="radio-label">CPC</label>
					<input type="radio" name="type" value="CPA" <?php echo ('CPA' == $type) ? 'checked="checked"' : ''; ?>/><label class="radio-label">CPA</label>
				</td>
			</tr>
			
			<!--  Whether it's needed when create an offer
			<tr>
				<td>Status:</td>
				<td>
					<select name="status">
						<option value="0" <?php echo ('0' == $status) ?  'selected="selected"' : ''; ?>>Pending</option>
						<option value="1" <?php echo ('1' == $status) ?  'selected="selected"' : ''; ?>>Active</option>
						<option value="2" <?php echo ('2' == $status) ?  'selected="selected"' : ''; ?>>Pause</option>
						<option value="3" <?php echo ('3' == $status) ?  'selected="selected"' : ''; ?>>Delete</option>
					</select>
				</td>
			</tr>
			 -->
			
			<tr>
				<td>Price:</td>
				<td><label class="dollar">$</label><input type="text" class="input-text" name="price" value="<?php if (isset($price)) echo $price;?>"/></td>
			</tr>
			<tr id="conv_pos">
				<td>Conversion Position:</td>
				<td>
					<select name="conv_pos">
						<option value="0" <?php echo ('0' == $conv_pos) ?  'selected="selected"' : ''; ?>>Landing</option>
						<option value="1" <?php echo ('1' == $conv_pos) ?  'selected="selected"' : ''; ?>>Basic Register</option>
						<option value="2" <?php echo ('2' == $conv_pos) ?  'selected="selected"' : ''; ?>>Full Register</option>
						<option value="3" <?php echo ('3' == $conv_pos) ?  'selected="selected"' : ''; ?>>Download</option>
						<option value="4" <?php echo ('4' == $conv_pos) ?  'selected="selected"' : ''; ?>>Installation</option>
						<option value="5" <?php echo ('5' == $conv_pos) ?  'selected="selected"' : ''; ?>>Conversion 1</option>
						<option value="6" <?php echo ('6' == $conv_pos) ?  'selected="selected"' : ''; ?>>Conversion 2</option>
						<option value="7" <?php echo ('7' == $conv_pos) ?  'selected="selected"' : ''; ?>>Conversion 3</option>
						<option value="8" <?php echo ('8' == $conv_pos) ?  'selected="selected"' : ''; ?>>Conversion 4</option>
						<option value="9" <?php echo ('9' == $conv_pos) ?  'selected="selected"' : ''; ?>>Conversion 5</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>IP Window:</td>
				<td><input type="text" class="input-text" name="ip_window" value="<?php echo (isset($ip_window)) ? $ip_window : 30;?>"/>days</td>
			</tr>
			<tr>
				<td>Cookie Window:</td>
				<td><input type="text" class="input-text" name="cookie_window" value="<?php echo (isset($cookie_window)) ? $cookie_window : 30;?>"/>days</td>
			</tr>
			<tr>
				<td colspan="2" class="t-right"><input type="submit" class="input-submit" value="Save"/></td>
			</tr>
		</table>
		</form>
	</fieldset>
</div>
<script type="text/javascript">
	$(function(){
		$('#conv_pos').hide();
		$("input[name=type]").click(function(){
			if($("input[name=type][value=CPA]").attr('checked')){
				$('#conv_pos').show();
			}else{
				$('#conv_pos').hide();
			}
		});
	});
</script>
<?php $this->_endblock(); ?>